'''
Created on Mar 13, 2012

@author: zahy
'''
import pyglet

window = pyglet.window.Window()
label = pyglet.text.Label('1',
                          font_name='Times New Roman',
                          font_size=36,
                          x=window.width//2, y=window.height//2,
                          anchor_x='center', anchor_y='center')
ball_image = pyglet.image.load('square.jpg')
ball = pyglet.sprite.Sprite(ball_image, x=5, y=5)


@window.event
def on_draw():
    window.clear()
    label.draw()
    ball.draw()    
    pyglet.graphics.draw(2, pyglet.gl.GL_POINTS,
    ('v2i', (10, 15, 30, 35))
)
    pyglet.graphics.glColor3f(100,0,0)
    pyglet.graphics.draw_indexed(4, pyglet.gl.GL_QUADS,
    [0, 1, 2, 0, 2, 3, 4],
    ('v2i', (0, 0,
             150, 0,
             150, 150,
             0, 150))
)


def update(dt):
    #label.text = str(int(label.text)*2)
    if ball.x < window.width//2: 
        ball.x+=1
    if ball.y < window.height//2:             
        ball.y+=1
            
pyglet.clock.schedule_interval(update, 1/120.0)    
pyglet.app.run()
    